package com.liugan.magic.actor.base;

import org.loon.framework.android.game.core.geom.RectBox;
import org.loon.framework.android.game.core.graphics.component.Actor;

import com.liugan.magic.changes.ChangesThings;
import com.liugan.magic.screen.GameScreen;
import com.liugan.magic.screen.PointXY;
import com.liugan.magic.screen.layer.GameLayer;

public class BaseActor extends Actor {
	
	protected  int newy,newx;
	protected  GameLayer layer;
	public  boolean onGround=false;
	protected  double vx, vy;
	public  String isdir;//面向的方向
	public PointXY totalXY=new PointXY(),offsetXY=new PointXY();
	public ChangesThings ct=new ChangesThings();//对象属性
	
	public boolean isOnGround() {
		return onGround;
	}
	public double getVx() {
		return vx;
	}
	public double getVy() {
		return vy;
	}
	//计算x方向碰撞盒子
	public RectBox getrectboxx(){
		return new RectBox(getX()+ct.rx,getY()+ct.ry,getWidth()-ct.rwidth,getHeight()-ct.rheight);
	}
	
	//计算y方向碰撞盒子
	public RectBox getrectboxy(){
		return new RectBox(getX()+ct.rx,getY()+ct.ry,getWidth()-ct.rwidth,getHeight()-ct.rheight);
	}
	
	//碰撞检测 直接检测
	public boolean isCollisionx(BaseActor otheractor){
		if (getrectboxx().intersects(otheractor.getrectboxx())) {
			return true;
		}
		return false;
	}
	
	//碰撞检测 直接检测
	public boolean isCollisiony(BaseActor otheractor){
		if (getrectboxy().intersects(otheractor.getrectboxy())) {
			return true;
		}
		return false;
	}
	
	//不使用指定缩小的矩形边框
//	public boolean isCollisiony_nouse(BaseActor otheractor){
//		if (this.getRectBox().intersects(otheractor.getRectBox())) {
//			return true;
//		}
//		return false;
//	}
	
	//使用指定的宽度和高度
	@Override
	public int getHeight() {
		if (ct.rectboxheight!=0){
			return ct.rectboxheight;
		}
		return super.getHeight();
	}
	@Override
	public int getWidth() {
		if (ct.rectboxwidth!=0){
			return ct.rectboxwidth;
		}
		return super.getWidth();
	}
	
}
